const NORMAL_ORDER_TYPE = ['GH', 'ZX', 'DZ', 'SH', 'WT', 'TW', 'DH', 'TD', 'XZ', 'TS', 'KS', 'FX', 'dh'];
const VIP_ORDER_TYPE = ['HY', 'hy'];
const TOPUP_ORDER_TYPE = ['CZ', 'cz'];




function getMixinByOrderType() {
	return {
		methods: {
			async getOrderDetail(taskCode) {
				switch (this.orderType) {
					case 'hy':
						this.restUrl = this.$restUrl.getOrderDetailVip;
						break;
					case 'HY':
						this.restUrl = this.$restUrl.getOrderDetailVip;
						break;
					case 'cz':
						this.restUrl = this.$restUrl.getOrderDetailTopup;
						break;
					case 'CZ':
						this.restUrl = this.$restUrl.getOrderDetailTopup;
						break;
					case 'KS':
						this.restUrl = this.$restUrl.getOrderDetailQuickly;
						break;
					case 'FX':
						this.restUrl = this.$restUrl.getOrderDetailAnalysis;
						break;
					case 'dh':
						this.restUrl = this.$restUrl.getOrderDetailMobile;
						break;
					case 'DH':
						this.restUrl = this.$restUrl.getOrderDetailMobile;
						break;
				}
				const {
					data
				} = await this.$u.post(this.restUrl, {
					task_code: this.taskCode,
				})
				console.log(data);
				// const nowTime = parseInt(+new Date() / 1000);
				// const expirationTime = Number(data.created_at) + Number(data.excess_time);
				// const countDown = parseInt(expirationTime - nowTime);
				this.orderDetail = data;
				// this.$set(this.orderDetail, 'countDown', countDown);
			}
		},
		computed: {
			orderStatus() {
				if (!this.orderDetail) {
					return
				} else if (NORMAL_ORDER_TYPE.indexOf(this.orderType) != -1) {
					if (this.orderDetail.pay_status == 1) {
						return {
							orderStyle: 'paying',
							orderBtnText: '立即支付',
							orderTitle: '待支付',
							orderBtnClick: this.payAgain
						}
					} else if (this.orderDetail.pay_status == 2) {
						if (this.orderDetail.status == 1) {
							return {
								orderStyle: 'processed',
								orderBtnText: '返回',
								orderTitle: '待处理',
								tips: '订单审核中，请您耐心等待',
								orderBtnClick: this.comeback
							}
						} else if (this.orderDetail.status == 2) {
							return {
								orderStyle: 'processed',
								orderBtnText: this.orderType == 'KS' ? '继续咨询' : '返回',
								orderTitle: '进行中',
								tips: '订单未完成，您可选择继续咨询',
								orderBtnClick: this.orderType == 'KS' ? this.toConsult : this.comeback
							}
						} else if (this.orderDetail.status == 3) {
							return {
								orderStyle: 'complate',
								orderBtnText: '立即评价',
								orderTitle: '已支付',
								tips: '订单已完成，请评价我们的服务',
								orderBtnClick: this.toEvaluation
							}
						}
					} else if (this.orderDetail.pay_status == 3) {
						return {
							orderStyle: 'cancel',
							orderBtnText: '重新下单',
							orderTitle: '已取消',
							tips: '订单已关闭，您可点击下方按钮重新下单',
							orderBtnClick: this.placeOrderAgain
						}
					} else if (this.orderDetail.pay_status == 4) {
						if (this.orderDetail.status == 1) {
							return {
								orderStyle: 'vip',
								orderBtnText: '返回',
								orderTitle: '待处理',
								tips: '您是小律懂法VIP，尊享VIP免支付，订单审核中',
								orderBtnClick: this.comeback
							}
						} else if (this.orderDetail.status == 2) {
							return {
								orderStyle: 'vip',
								orderBtnText: this.orderType == 'KS' ? '继续咨询' : '返回',
								orderTitle: '进行中',
								tips: '您是小律懂法VIP，尊享VIP免支付，订单进行中，点击继续咨询',
								orderBtnClick: this.orderType == 'KS' ? this.toConsult : this.comeback
							}
						} else if (this.orderDetail.status == 3) {
							return {
								orderStyle: 'vip',
								orderBtnText: '立即评价',
								orderTitle: '已支付',
								tips: '您是小律懂法VIP，尊享VIP免支付，订单已完成，点击评价本次服务',
								orderBtnClick: this.toEvaluation
							}
						}
					}
				} else if (VIP_ORDER_TYPE.indexOf(this.orderType) != -1) {
					if (this.orderDetail.pay_status == 1) {
						return {
							orderStyle: 'paying',
							orderBtnText: '立即支付',
							orderTitle: '待支付',
							orderBtnClick: this.payAgain
						}
					} else if (this.orderDetail.pay_status == 2) {
						return {
							orderStyle: 'complate',
							orderBtnText: '返回',
							orderTitle: '已支付',
							tips: '订单已完成，已成为小律懂法会员',
							orderBtnClick: this.comeback
						}
					} else if (this.orderDetail.pay_status == 3) {
						return {
							orderStyle: 'overdue',
							orderBtnText: '开通会员',
							orderTitle: '已过期',
							tips: '会员身份已过期，开通会员即可继续免费咨询',
							orderBtnClick: this.renewal
						}
					} else if (this.orderDetail.pay_status == 4) {
						return {
							orderStyle: 'cancel',
							orderBtnText: '重新下单',
							orderTitle: '已取消',
							tips: '订单已关闭，您可点击下方按钮重新下单',
							orderBtnClick: this.renewal
						}
					}
				} else if (TOPUP_ORDER_TYPE.indexOf(this.orderType) != -1) {
					if (this.orderDetail.pay_status == 1) {
						return {
							orderStyle: 'paying',
							orderBtnText: '立即支付',
							orderTitle: '待支付',
							orderBtnClick: this.topupAgain
						}
					} else if (this.orderDetail.pay_status == 2) {
						return {
							orderStyle: 'complate',
							orderBtnText: '返回',
							orderTitle: '已支付',
							tips: '充值余额成功，订单已完成',
							orderBtnClick: this.comeback
						}
					} else if (this.orderDetail.pay_status == 3) {
						return {
							orderStyle: 'cancel',
							orderBtnText: '重新充值',
							orderTitle: '已取消',
							tips:'订单已关闭，您可点击下方按钮重新下单',
							orderBtnClick: this.toTopup
						}
					}
				}
			}
		}
	}
}

export {
	getMixinByOrderType
}
